<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core">
    <ui:composition template="/Modelos/Principal/modelo-principal.xhtml">
        <ui:define name="content">

            <p:panel header="Consulta Departamentos Cadastrados">
                <p:growl showDetail="true"/>


                <h:form>
                    <f:facet name="header">  
                        Tabela de Departamentos 
                    </f:facet>  
                    <p:dataTable value="#{departamentoBean.departamentos}" var="item">
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Código"/>
                            </f:facet>
                            <h:outputText value="#{item.idDepartamento}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Nome"/>
                            </f:facet>
                            <h:outputText value="#{item.nome}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Setor"/>
                            </f:facet>
                            <h:outputText value="#{item.setor}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Ação"/>
                            </f:facet>
                            <p:commandButton action="#{departamentoBean.apagar()}" ajax="false" icon="ui-icon-trash">
                            <f:setPropertyActionListener value="#{item}" target="#{departamentoBean.departamento}"/>
                            </p:commandButton>
                            
                            <p:commandButton action="cadastro-departamento" icon="ui-icon-pencil">
                                <f:setPropertyActionListener value="#{item}" target="#{departamentoBean.departamento}"/>
                            </p:commandButton>
                        </p:column>
                    </p:dataTable>
                </h:form>

            </p:panel>

        </ui:define>
    </ui:composition>
</html>

